Replace <literal> nodes with <constant> for constants - #2310
Conversation
Girgias
left a comment
There was a problem hiding this comment.
Thanks for tackling this, this makes sense.
However, I'd wait a bit to check with translations as this does do some busy work for them (and as I'm being on the French translation and the constant tag does not generates links it would be nice that I can tackle more urgent stuff)
|
It would make sense to coordinate this with #1963 also to not repeat the work multiple times. |
|
Great! Let me inherit these changes here and mark the other PR in a TO-DO list in order to make the dependency explicit. |
b950b26 to
bae3592
Compare
b8da203 to
21eb6eb
Compare
Girgias
left a comment
There was a problem hiding this comment.
Overall OK but I'm going to wait to merge this as this is a QA change.
Also it would be nice to fix the whitespaces in another PR that one can skip-revcheck as those clutter the PR.
Whitespace changes were reverted 👍 |
|
Sorry for the delay in this, could you rebase the PR on master? |
|
Rebased. |
|
There are a few constants with replaceable parts that use These are the ones I've found in |
|
I think these are missing cases @haszi. Thank you for pointing. |
|
The cases using the |
Girgias
left a comment
There was a problem hiding this comment.
Not sure the runkit changes are appropriate, nor the Enumeration docs as those refer to inline examples, maybe using code is more appropriate but I need to have a think about this.
|
You can drop the changes to the migrated extensions. It will make reviewing this easier too. |
| The only limitation is that the <literal>class</literal> keyword still | ||
| cannot be used as a constant name, otherwise it would conflict with the | ||
| class name resolution syntax (<literal>ClassName::class</literal>). | ||
| class name resolution syntax (<constant>ClassName::class</constant>). |
There was a problem hiding this comment.
This is not a constant. It shuld stay as literal.
There was a problem hiding this comment.
doc-en/language/oop5/constants.xml
Lines 64 to 68 in d4f96da
There was a problem hiding this comment.
Fair enough, it is also called a magic constant here https://www.php.net/manual/en/language.constants.magic.php
However, I don't think we are going for semantics here. The change is about making the constants link up properly, and magic "constant" ::class cannot do that. So, using <constant> is not useful here. Compare how it is rendered right now on https://www.php.net/manual/en/migration70.other-changes.php or https://www.php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class.class
| name resolution. | ||
| To obtain the fully qualified name of a class <literal>ClassName</literal> | ||
| use <literal>ClassName::class</literal>. This is particularly useful with | ||
| use <constant>ClassName::class</constant>. This is particularly useful with |
| This declaration creates a new enumerated type named <literal>Suit</literal>, which has | ||
| four and only four legal values: <literal>Suit::Hearts</literal>, <literal>Suit::Diamonds</literal>, | ||
| <literal>Suit::Clubs</literal>, and <literal>Suit::Spades</literal>. Variables may be assigned | ||
| four and only four legal values: <constant>Suit::Hearts</constant>, <constant>Suit::Diamonds</constant>, |
There was a problem hiding this comment.
I don't think these are constants.
| The <literal>query()</literal> function can now proceed safe in the knowledge that | ||
| <literal>$order</literal> is guaranteed to be either <literal>SortOrder::Asc</literal> | ||
| or <literal>SortOrder::Desc</literal>. Any other value would have resulted in a | ||
| <literal>$order</literal> is guaranteed to be either <constant>SortOrder::Asc</constant> |
| &reftitle.returnvalues; | ||
| <para> | ||
| Returns an <literal>IntlChar::PROPERTY_</literal> constant value, | ||
| Returns an <constant>IntlChar::PROPERTY_</constant> constant value, |
There was a problem hiding this comment.
I think you are missing replaceable here.
172 occurrences were replaced from
<literal>([A-Za-z0-9_]+)::([A-Z0-9_\*]+)</literal>to<constant>$1::$2</constant>.See #2306 (comment).
TODO: